package com.cyy.springbootinit.model.vo;

import cn.hutool.json.JSONUtil;
import com.cyy.springbootinit.model.entity.Building;
import com.cyy.springbootinit.model.entity.EquipmentData;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 设备数据表视图
 *
 * @author 程序员cyy</a>
 * @from cyy</a>
 */
@Data
public class EquipmentDataVO implements Serializable {

    /**
     * 自增整数，主键，设备数据记录ID
     */
    private Integer dataId;

    /**
     * 整数，设备ID（通过关联表实现关联，此处暂不体现外键）
     */
    private Integer equipmentId;

    /**
     * 浮点数，历史读表数据（如电量读数、水量读数等）
     */
    private Double readValue;

    //当前读表数据
    private Double currentReadValue;

    //花费
    private Double totalCost;

    /**
     * 浮点数，设备额度（通过计算得到）
     */
    private Double equipmentBalance;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;

    //设备信息
    private EquipmentInfoVO equipmentInfoVO;

    private static final long serialVersionUID = 1L;

    /**
     * 封装类转对象
     *
     * @param scoringResultVO
     * @return
     */
    public static EquipmentData voToObj(EquipmentDataVO scoringResultVO) {
        if (scoringResultVO == null) {
            return null;
        }
        EquipmentData scoringResult = new EquipmentData();
        BeanUtils.copyProperties(scoringResultVO, scoringResult);
        return scoringResult;
    }

    /**
     * 对象转封装类
     *
     * @param
     * @return
     */
    public static EquipmentDataVO objToVo(EquipmentData balanceWarning) {
        if (balanceWarning == null) {
            return null;
        }
        EquipmentDataVO scoringResultVO = new EquipmentDataVO();
        BeanUtils.copyProperties(balanceWarning, scoringResultVO);
        //scoringResultVO.setResultProp(JSONUtil.toList(scoringResult.getResultProp(), String.class));
        return scoringResultVO;
    }
}
